Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clear and reset functionality to Bloodhound #703

Merged
merged 4 commits into from
Mar 9, 2014

Conversation

jharding
Copy link
Contributor

See #694, #653, #223, and parts of #562.

Still need to add some test cases.

@jharding jharding added this to the v0.10.2 milestone Feb 18, 2014
@ahutchings
Copy link

It would be nice for the reset method to accept new data as an optional argument.

@mrtomtom
Copy link

I think it would be great it if you could selectively choose specific prefetch data to reset. For if you're searching multiple large datasets you don't want to refetch all of 'em if just one has changed. Also something like clients.reset(true); clients.initialize(true); resets the modal but does not reset the local storage?

@simonexmachina
Copy link
Contributor

FYI, merging this into our fork because we need a reset() method too :)

@jharding
Copy link
Contributor Author

jharding commented Mar 7, 2014

@mrtomtom can you clarify what you meant by this:

Also something like clients.reset(true); clients.initialize(true); resets the modal but does not reset the local storage?

@jharding
Copy link
Contributor Author

jharding commented Mar 9, 2014

For the sake of posterity, this patch makes the following things possible:

var engine = new Bloodhound({ /* ... */ });

// 1. clear suggestions loaded from local and prefetch
engine.clear();

// 2. clear prefetch data stored in local storage
engine.clearPrefrechCache();

// 3. clear cache of responses generated by remote requests
engine.clearRemoteCache();

// 4. reinitialize the suggestion engine i.e. load data 
// from `local` and `prefetch`
engine.initialize(true); // have to pass true in order to reinitialize

@jharding jharding merged commit d4dfccc into twitter:integration-0.10.2 Mar 9, 2014
@jharding jharding deleted the clear-prefetch branch March 12, 2014 08:06
@mrtomtom
Copy link

@jharding Sorry was away from keyboard. Just grabbed the latest version and using the code below it works perfectly.
engine.clear();
engine.clearPrefrechCache();
engine.initialize(true);

@youssman
Copy link

Just a simple remark regarding syntax :

It's engine.clearPrefetchCache() and not engine.clearPrefrechCache()

That's all 😄 thanks for this library !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants